<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <ui:composition template="/shared/_layout.xhtml">
        <ui:define name="title">
            Espace d'administration de BooXtore.com
        </ui:define>
        <ui:define name="css">
            <h:outputStylesheet library="css" name="form.css"/>
        </ui:define>
        <ui:define name="content">
            <f:event listener="#{accountLogin.isNotLogged()}" type="preRenderView" />
            <f:event listener="#{libraryManager.initialize()}" type="preRenderView" />
            <h1>Création d'un livre existant.</h1>
            <h:form>
                <p>
                    <h:messages errorClass="errorMessage" infoClass="infoMessage" warnClass="warnMessage"/>
                </p>
                <table>
                    <tr>
                        <td>
                            <h:outputLabel value="Nom" for="name"/>
                        </td>
                        <td>
                            <h:inputText required="true" size="45" maxlength="45" label="Nom" id="name" value="#{libraryManager.article.name}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel value="Description" for="summary"/>
                        </td>
                        <td>
                            <h:inputTextarea cols="40" rows="10" required="true" label="Description" id="summary" value="#{libraryManager.article.summary}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel value="Date de parution" for="releaseDate"/>
                        </td>
                        <td>
                            <h:inputText required="true" value="#{libraryManager.article.releaseDate}" id="releaseDate" label="Date de parution" maxlength="10" size="10">
                                <f:convertDateTime pattern="yyyy-MM-dd"/>
                            </h:inputText> ANNEE-MM-JJ
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel value="Référence" for="reference"/>
                        </td>
                        <td>
                            <h:inputText required="true" maxlength="45" size="45" id="reference" label="Référence" value="#{libraryManager.article.ref}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel value="Prix" for="price"/>
                        </td>
                        <td>
                            <h:inputText required="true" id="price" label="Prix" value="#{libraryManager.article.price}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel value="Status" for="status"/>
                        </td>
                        <td>
                            <h:selectOneMenu label="Status" id="status" value="#{libraryManager.article.state}">
                                <f:selectItem itemLabel="Nouveautés" itemValue="1"/>
                                <f:selectItem itemLabel="En stock" itemValue="2"/>
                                <f:selectItem itemLabel="A venir" itemValue="3"/>
                                <f:selectItem itemLabel="En réapprovisionnement" itemValue="4"/>
                            </h:selectOneMenu>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel value="Limite des stocks" for="limitStock"/>
                        </td>
                        <td>
                            <h:inputText required="true" id="limitStock" label="Limite des stocks" value="#{libraryManager.article.limitStock}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel value="Quantité" for="quantityStock"/>
                        </td>
                        <td>
                            <h:inputText required="true" id="quantityStock" label="Quantité" value="#{libraryManager.article.quantityStock}"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel value="Editeur" for="editor"/>
                        </td>
                        <td>
                            <h:selectOneMenu required="true" id="editor" label="Editeur" value="#{libraryManager.article.idEditors.IDeditors}">
                                <c:forEach items="#{libraryManager.editors}" var="editor">
                                    <f:selectItem itemLabel="#{editor.name}" itemValue="#{editor.IDeditors}"/>
                                </c:forEach>
                            </h:selectOneMenu>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <h:outputLabel value="Catégorie" for="category"/>
                        </td>
                        <td>
                            <h:selectOneMenu id="category" label="Catégorie" value="#{libraryManager.article.idCategories.IDcategories}">
                                <c:forEach items="#{libraryManager.categories}" var="category">
                                    <f:selectItem itemLabel="#{category.name}" itemValue="#{category.IDcategories}"/>
                                </c:forEach>
                            </h:selectOneMenu>
                        </td>
                    </tr>
                </table>
                <p>
                    <h:commandButton value="Créer" action="#{libraryManager.create()}"/>
                    <h:outputText value=" "/>
                    <h:link outcome="/index" class="back" value="Annuler"/>
                </p>
            </h:form>
        </ui:define>
    </ui:composition>
</html>